import {request} from '@umijs/max';
import * as API from "@/services";
import {encryptVigenere} from "kf-web-library";
/**
 * 账号 + 密码 登录
 */
export async function passwordLogin(params: API.PasswordLoginReq, opts?: API.AxiosRequestOpts) {
  return request<API.RespResult<API.AuthInfo>>('/api/v1/account-login', {
    method: 'POST',
    data: {
      ...params,
      //password: encryptVigenere(params.password),
      //encrypted: true,
      clientType: "ADMIN_WEB"
    },
    ...(opts || {}),
  });
}

/**
 * 手机/邮箱 + 验证码 登录
 */
export async function verificationCodeLogin(params: API.VerificationCodeLoginReq) {
    return request<API.RespResult<API.AuthInfo>>('/api/v1/account-login', {
        method: 'POST',
        data: params,
    });
}

/**
 * TOKEN 登录 (一般是三方登录才会用这个)
 */
export async function tokenLogin(token: string, opts?: API.AxiosRequestOpts) {
    return request<API.RespResult<API.AuthInfo>>('/api/v1/login-token-parse', {
        method: 'POST',
        data: {
            token
        },
        ...(opts || {}),
    });
}





